<?php

namespace app\index\controller;

use app\admin\model\Card;
use app\admin\model\Chat;
use app\admin\model\ChatLog;
use app\admin\model\ClassQu;
use app\admin\model\Duty;
use app\admin\model\PushStore;
use app\admin\model\PushStoreRule;
use app\admin\model\Qu;
use app\admin\model\Reply;


use app\admin\model\ReplyInfo;
use app\admin\model\RobotAction;
use app\admin\model\RobotSet;
use app\admin\model\Staff;
use app\admin\model\StaffChatTime;
use app\admin\model\StaffReplyTime;
use app\admin\model\StaffTime;
use app\admin\model\Store;
use app\admin\model\Token;
use app\admin\model\User;
use app\admin\model\UserPvLog;
use app\common\ArrayObj;
use app\common\CommandCron;
use app\common\Common;
use app\http\Http;
use app\pxs\service\JwtService;
use app\sys\model\Conn;
use app\sys\model\Dict;
use app\sys\model\QyeDepartment as QyeDepartmentModel;
use app\sys\model\UrlSourceLog;

use app\sys\service\AliOss;

use app\sys\service\GateCli;

use app\sys\service\OfficeExe;


use GatewayClient\Gateway;
use GuzzleHttp\Client;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
use sensitive\SensitiveWord;
use app\sys\model\SensitiveWord as SensitiveWorkModel;
use test\ti;
use think\Container;
use think\Controller;
use think\Db;
use think\Exception;
use think\facade\Cache;
use think\facade\Env;
use think\facade\Log;
use think\facade\Request;
use think\worker\command\Worker;
use wechatcom\WechatComment;
use wework\WeWork;
use Workerman\Protocols\Websocket;
use function GuzzleHttp\Psr7\str;

class Index extends Controller
{
    public  $d = 1;
    public function index()
    {
        $ids = "1";
        $idArr = explode(",",$ids);
        print_r($idArr);
      echo   $_SERVER['DOCUMENT_ROOT'];
    }

    public function hello($name = 'ThinkPHP5')
    {
        return 'hello,' . $name;
    }

    public function getDepath()
    {
//        $corpId = Env::get("QYE.CORPID");
//        $secret = Env::get("QYE.APP_SECRET");
//        $we = new WeWork($corpId, $secret);
//        $res = $we->departmentList();
//        QyeDepartmentModel::add($res);
    }

    public function TisAll()
    {
//        $depart = 6;
//        $corpId = Env::get("QYE.CORPID");
//        $secret = Env::get("QYE.APP_SECRET");
//        $we = new WeWork($corpId, $secret);
//        $user = $we->userSimpleList($depart);
//        $userArr = [];
//        foreach ($user as $k => $v){
//            $userArr[] = $v->userid;
//        }
//        $url = Env::get("QYE.APP_BING_URL");
//        $url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid={$corpId}&redirect_uri=".$url."/bind-staff&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect";
//        $we->setMessage([],$userArr,"系统","",$url,"","pxs000000",$depart);
//        $we->sendMessage();
    }

    public function checkSignature()
    {
        $signature = $_GET["signature"];
        $timestamp = $_GET["timestamp"];
        $nonce = $_GET["nonce"];
        $echostr = $_GET["echostr"];
        $token = "1078220813";
        $tmpArr = array($token, $timestamp, $nonce);
        sort($tmpArr, SORT_STRING);
        $tmpStr = implode( $tmpArr );
        $tmpStr = sha1( $tmpStr );
        Log::info("checkSignature:".$signature."-".$tmpStr);
        if( $tmpStr == $signature ){
            return $echostr;
        }else{
            return false;
        }
    }
}
